Feat: cache discovery results and extract shared get_model_info#62
Closed
cosminacho wants to merge 2 commits into
Closed
Feat: cache discovery results and extract shared get_model_info#62cosminacho wants to merge 2 commits into
cosminacho wants to merge 2 commits into
Conversation
…nfo (#62) Add TTL-based caching (5 min) for get_available_models() to avoid redundant discovery calls when creating multiple models in a session. Extract shared model lookup logic into get_model_info() utility in the core package, reused by both the langchain factory and litellm client. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
cosminacho
added a commit
that referenced
this pull request
Apr 17, 2026
Add caching for model discovery and centralize model lookup logic in UiPathBaseSettings so all consumers (LangChain factory, LiteLLM client) share the same cached discovery and filtering. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_available_models()with@lru_cacheon bothPlatformSettingsandLLMGatewaySettings, avoiding redundant discovery endpoint calls when creating multiple models in a sessionget_model_info()utility touipath.llm_client.utils.discovery— the model lookup logic (filter by name, vendor, BYOM connection ID, prefer UiPath-owned) was duplicated between the langchain factory and litellm client__hash__ = object.__hash__toUiPathBaseSettingsso@lru_cacheworks on instance methods (pydantic models aren't hashable by default)Packages affected: core + langchain
Test plan
get_model_infotests: name matching, case-insensitive, vendor filter, BYOM connection ID filter, UiPathOwned preference, error casesruff check && ruff format --check && pyright && pytest tests— 1519 passed)🤖 Generated with Claude Code